<?php
$this->useClass('Uniform_Object');

class Uniform_Community_Profile extends Uniform_Object
{
	public function data ()
	{
		return $this->what()->data;
	} // end of method data
	/** кол-во записей в сообществе. */
	public function itemsCount ()
	{
		$ql = 'select count objects where allfeed.oid > 0 and allfeed.community_oid = :0';
		$items_count = $this->service->getStore()->find( $ql, array($this['oid']) )->next();
		return $items_count->data['count'];
	} // end of method itemsCount
	/** сколько дней прошло с момента создания сообщества. */
	public function daysBtwCreate ()
	{
		$current_time = time();
		$create_time = $this['ctime']->unix_mark();
		$seconds_btw_create = $current_time - $create_time;

		$days_btw_create = $seconds_btw_create/60/60/24;
		return $days_btw_create;
	} // end of method daysBtwCreate
	/** сколько постится итемов в день. */
	public function itemsPD ()
	{
		return number_format($this['items_count']/$this['days_btw_create'],1);
	} // end of method itemsPD
	/** кол-во комментов */
	public function commentsCount ()
	{
		// кол-во комментов
		$sql = "
			SELECT count(*) as comments_count
			FROM store_class_comment cm
			INNER JOIN store_class_allfeed af on cm.item_oid = af.oid and af.community_oid = ".$this['oid']."
			INNER JOIN t_acl_tree tat ON tat.id_object = cm.oid AND tat.is_deleted = 0
			WHERE cm.is_deleted = 0";
		$result = $this->service->getStore()->db->QueryOne($sql);

		return $result['comments_count'];
	} // end of method commentsCount

}

